package org.dreamwork.jasmine2.restful.client.gui.ui;

import javax.swing.*;
import java.awt.*;

/**
 * Created by IntelliJ IDEA.
 * User: seth.yang
 * Date: 2014/12/9
 * Time: 1:06
 */
public class CloseIcon implements Icon {
    private int x, y;
    @Override
    public void paintIcon (Component c, Graphics g, int x, int y) {
        this.x = x;
        this.y = y;
        Graphics2D g2 = (Graphics2D) g;
        Color color = g.getColor ();
        g2.translate (x, y);
//        System.out.println ("x = " + x + ", y = " + y);
        g2.setColor (Color.GRAY);
        g2.setStroke (new BasicStroke (2));
        g.drawLine (5, 5, 11, 11);
        g.drawLine (5, 11, 11, 5);
//        g2.setColor (Color.red);
//        g.drawRect (0, 0, 16, 16);
        g2.translate (-x, -y);
    }

    @Override
    public int getIconWidth () {
        return 16;
    }

    @Override
    public int getIconHeight () {
        return 16;
    }

    public Rectangle getBound () {
        return new Rectangle (x, y, 16, 16);
    }
}
